package com.dnjn.happiness.survey.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dnjn.happiness.common.core.annotation.Excel;
import com.dnjn.happiness.common.core.model.PositionLadderVO;
import com.dnjn.happiness.common.core.model.SysPostVO;
import com.dnjn.happiness.common.core.web.domain.BaseEntity;
import com.dnjn.happiness.system.api.domain.SysDept;
import com.dnjn.happiness.system.api.domain.SysUser;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 问卷对象 svy_survey
 *
 * @author happiness
 * @date 2023-10-23
 */
@Schema(name = "Survey", description = "问卷")
@Accessors(chain = true)
@Getter
@Setter
@TableName("svy_survey")
public class Survey extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * PK
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "survey_id", type = IdType.ASSIGN_ID)
    private Long surveyId;


    

    /**
     * 问卷对应的模板Id
     */
    @Schema(description = "问卷对应的模板Id")
    @Excel(name = "问卷对应的模板Id")
    private Long surveyTemplateId;

    /**
     * 问卷类型 COMMON-普通, COMMUNICATE-沟通
     */
    @Schema(description = "问卷类型BUILTIN-内置问卷,CUSTOM-自定义问卷")
    @Excel(name = "问卷类型BUILTIN-内置问卷,CUSTOM-自定义问卷")
    private String surveyType;

    /**
     * 发起人id
     */
    @Schema(description = "发起人id")
    @Excel(name = "发起人id")
    private Long initiatorId;

    /**
     * 问卷标题
     */
    @Schema(description = "问卷标题")
    @Excel(name = "问卷标题")
    private String surveyTitle;

    /**
     * 问卷描述
     */
    @Schema(description = "问卷描述")
    @Excel(name = "问卷描述")
    private String surveyDescription;

    /**
     * $column.columnComment
     */
    @Schema(description = "${comment}")
    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
    private Long ordinal;

    /**
     * READY-创建中 PROCESSING-已下发 FINISHED-已结束（到结束时间后）
     */
    @Schema(description = " READY-创建中 PROCESSING-已下发 FINISHED-已结束,选择创建问卷需要前端将 surveyStatus设置为READY,小程序选择下发问卷需设置为PROCESSING")
    @Excel(name = " READY-创建中 PROCESSING-已下发 FINISHED-已结束", readConverterExp = "到=结束时间后")
    private String surveyStatus;

    /**
     * 开始时间
     */
    @Schema(description = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime dateStart;

    /**
     * 结束时间
     */
    @Schema(description = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime dateEnd;

    /**
     * $column.columnComment
     */
    @Schema(description = "厂区id", requiredMode = Schema.RequiredMode.REQUIRED)
    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
    private Long siteId;

    /**
     * 题库模块id
     */
    @Schema(description = "题库模块id", requiredMode = Schema.RequiredMode.REQUIRED)
    @Excel(name = "题库模块id")
    private Long tikuTagsId;

    @Schema(description = "问卷所选题库id集合")
    @TableField(exist = false)
    private String tikuIds;

    /**
     * 是否删除|0-否 1-是|valid
     */
    @Schema(description = "是否删除|0-否 1-是|valid")
    @Excel(name = "是否删除|0-否 1-是|valid")
    private String deleted;
    @Schema(description = "下发状态")
    private String issuedStatus;

    private Integer minScore;

    private Integer maxScore;

    @TableField(exist = false)
    private String result;
    //问卷发起人姓名
    @TableField(exist = false)
    private String initiatorName;

    @TableField(exist = false)
    @Schema(description = "指定问卷参加人", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private List<Long> userIds;

    @TableField(exist = false)
    @Schema(description = "指定参加的部门Id集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private List<Long> deptIdList;

    @Schema(description = "指定参加的部门Id集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableField(fill = FieldFill.UPDATE)
    private String deptIds;

    @Schema(description = "指定参加岗位Id集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableField(fill = FieldFill.UPDATE)
    private String postIds;

    @Schema(description = "指定参加职级集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableField(fill = FieldFill.UPDATE)
    private String positionIds;

    @Schema(description = "指定参加类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
//    @TableField(fill = FieldFill.UPDATE)
    private String type;

    @TableField(exist = false)
    @Schema(description = "参加人对象列表", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private List<SysUser> userList;

    @TableField(exist = false)
    @Schema(description = "查看我需要参与的问卷", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Long watchId;
    @TableField(exist = false)
    @Schema(description = "题库类型名称", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private String label;

    @TableField(exist = false)
    @Schema(description = "选择题目的id")
    private List<Long> timuIds;

    @TableField(exist = false)
    @Schema(description = "这条问卷记录的状态,已参与,未参与")
    private String recordStatus;
    @TableField(exist = false)
    private Long communicateId;
    @Schema(description = "个人详情表-查看具体点进去的人")
    @TableField(exist = false)
    private String userId;

    @TableField(exist = false)
    private String answerAppraise;
    @Schema(description = "题库id")
    @TableField(exist = false)
    private Long tikuId;

    @TableField(exist = false)
    private Integer surveyScore;

    @TableField(exist = false)
    private String recordTime;

    @TableField(exist = false)
    private Integer grade;

    //发起人头像
    @TableField(exist = false)
    private String initiatorAvatar;
    /**
     * 问卷所属区间集合
     */
    @TableField(exist = false)
    private List<SurveyIntervalScore> intervalScoreList;

    /**
     * 是否查看所有
     */
    @TableField(exist = false)
    private Boolean whetherAllPermissions;

    @TableField(exist = false)
    private String startTime;

    @TableField(exist = false)
    private String endTime;

    @TableField(exist = false)
    private List<SurveyRecord> recordList;

    @TableField(exist = false)
    private List<SysDept> selectDeptList;

    @TableField(exist = false)
    private List<SysPostVO> selectPostList;

    @TableField(exist = false)
    private List<PositionLadderVO> selectPosttionList;


    @Schema(description = "选中的人员列表,回显用", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableField(fill = FieldFill.UPDATE)
    private String checkedUserIds;

    /**
     * 问卷类型 COMMON-普通, COMMUNICATE-沟通
     */
    @Schema(description = "考核-check 问卷-survey")
    @TableField(exist = false)
    private String tikuType;

    @Schema(description = "问卷问题类型：CHARACTER 人格;PERSONALITY 性格;COMMON 普通")
    private String questionType;
    @TableField(exist = false)
    private Long deptId;

    @TableField(exist = false)
    private Long teamId;

    @Schema(description = "问卷答题人数")
    @TableField(exist = false)
    private Long count;


    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("surveyId", getSurveyId())
                .append("surveyType", getSurveyType())
                .append("initiatorId", getInitiatorId())
                .append("surveyTitle", getSurveyTitle())
                .append("surveyDescription", getSurveyDescription())
                .append("ordinal", getOrdinal())
                .append("surveyStatus", getSurveyStatus())
                .append("dateStart", getDateStart())
                .append("dateEnd", getDateEnd())
                .append("siteId", getSiteId())
                .append("tikuTagsId", getTikuTagsId())
                .append("remark", getRemark())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("deleted", getDeleted())
                .append("version", getVersion())
                .toString();
    }
}
